package com.splic.product.service.impl;

import java.util.Date;
import java.util.List;
import com.splic.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.splic.product.mapper.UserMotionRankingCountryMapper;
import com.splic.product.domain.UserMotionRankingCountry;
import com.splic.product.service.UserMotionRankingCountryService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 用户运动量全国排名统计Service业务层处理
 * 
 * @author singe
 * @date 2022-02-16
 */
@Service
public class UserMotionRankingCountryServiceImpl implements UserMotionRankingCountryService
{
    @Autowired
    private UserMotionRankingCountryMapper userMotionRankingCountryMapper;

    /**
     * 查询用户运动量全国排名统计
     * 
     * @param id 用户运动量全国排名统计主键
     * @return 用户运动量全国排名统计
     */
    @Override
    public UserMotionRankingCountry selectUserMotionRankingCountryById(Long id)
    {
        return userMotionRankingCountryMapper.selectUserMotionRankingCountryById(id);
    }

    /**
     * 查询用户运动量全国排名统计列表
     * 
     * @param userMotionRankingCountry 用户运动量全国排名统计
     * @return 用户运动量全国排名统计
     */
    @Override
    public List<UserMotionRankingCountry> selectPageList(UserMotionRankingCountry userMotionRankingCountry)
    {
        return userMotionRankingCountryMapper.selectUserMotionRankingCountryList(userMotionRankingCountry);
    }

    /**
     * 查询用户运动量全国排名统计列表
     *
     * @param userMotionRankingCountry 用户运动量全国排名统计
     * @return 用户运动量全国排名统计
     */
    @Override
    public List<UserMotionRankingCountry> selectUserMotionRankingCountryList(UserMotionRankingCountry userMotionRankingCountry)
    {
        return userMotionRankingCountryMapper.selectUserMotionRankingCountryList(userMotionRankingCountry);
    }

    /**
     * 新增用户运动量全国排名统计
     * 
     * @param userMotionRankingCountry 用户运动量全国排名统计
     * @return 结果
     */
    @Override
    public int insert(UserMotionRankingCountry userMotionRankingCountry)
    {
        userMotionRankingCountry.setCreateTime(DateUtils.getNowDate());
        return userMotionRankingCountryMapper.insert(userMotionRankingCountry);
    }

    /**
     * 修改用户运动量全国排名统计
     * 
     * @param userMotionRankingCountry 用户运动量全国排名统计
     * @return 结果
     */
    @Override
    public int update(UserMotionRankingCountry userMotionRankingCountry)
    {
        userMotionRankingCountry.setUpdateTime(DateUtils.getNowDate());
        return userMotionRankingCountryMapper.update(userMotionRankingCountry);
    }


    /**
     * 删除用户运动量全国排名统计信息
     * 
     * @param id 用户运动量全国排名统计主键
     * @return 结果
     */
    @Override
    public int deleteById(Long id)
    {
        return userMotionRankingCountryMapper.deleteById(id);
    }
    /**
     * 修改用户运动量全国排名统计
     *
     * @param userMotionRankingCountry 用户运动量全国排名统计信息
     * @return 结果
     */
    @Override
    @Transactional
    public int saveOrUpdate(UserMotionRankingCountry userMotionRankingCountry)
    {
        if(userMotionRankingCountry.getId() != null){
            userMotionRankingCountry.setUpdateTime(new Date());
            return userMotionRankingCountryMapper.update(userMotionRankingCountry);
        }else{
            userMotionRankingCountry.setCreateTime(new Date());
            return userMotionRankingCountryMapper.insert(userMotionRankingCountry);
        }
    }
}
